<template>
  <div class="cesium-viewer-wapper">
    <div id="cesium-viewer" />
    <viewerSettingSidebar :viewerSource="viewerSource" />
    <div class="tool-box-left-top">
      <!-- <div class="slider-box-wrapper"><slider-box v-model:value="relativeHeight" :max="10000" /></div> -->
      <!-- <div class="select-box-wrapper"><a-checkbox v-model:checked="shadows">shadows</a-checkbox></div> -->
      <!-- <div class="select-box-wrapper"><select-box :options="sizeOptions" /></div> -->
    </div>
    <div class="tool-box-left-bottom"></div>
    <GlobeRotater showTime startOnMount :viewerSource="viewerSource" :clockOptions="clockOptions" />
    <MousePosition show :viewerSource="viewerSource" />
  </div>
</template>

<script>
// import * as Cesium from '@cesiumjs';
import { defineComponent, ref, watch } from 'vue';
import { SelectBox, SliderBar } from '@components/widgets';
import { G3V } from '@g3x';
import {MousePosition,viewerSettingSidebar,GlobeRotater} from '@g3x/g3v/ui';

const g3vOptions = {
  defaultViewRectangle: G3V.defaultViews.global.china.rectangle,
  viewers:[{
    dom: "cesium-viewer",
    name: "viewer1",
    title: "viewer#01",
    viewer:{
      imagery: { type: 'arcgisImagery', options: { brightness: 1, show: true } },
      imageryProvider: null,
      terrain: { type: 'default', options: { requestVertexNormals: true, requestWaterMask: true } },
      terrainProvider: null,
      shadows: false,
    },
    layers:[
      { type: 'tdtIboMap', options: { brightness: 1, show: true } },
      { type: 'tdtImgAnno', options: { brightness: 1, show: true } },
      // { type: 'darkMask', options: { brightness: 1, alpha: 0.9 } },
      { type: 'graticule', options: { brightness: 1, show: true } }
    ],
    globe: {
      depthTestAgainstTerrain: false,
      enableLighting: true //启用以太阳为光源的地球
    },
    bottomContainer: false,
    navigation: {
      // defaultResetView: G3V.defaultViews.global.china.rectangle ,
      defaultResetView: null //flyHome
    },
    hideLayers: false,
  // },{
  //   dom: "cesium-viewer#2",
  //   name: "viewer2",
  //   title: "viewer 2",
  //   options:{
  //     imagery: { type: 'arcgisImagery', options: { brightness: 1, show: true } },
  //     imageryProvider: null,
  //     terrain: { type: 'default', options: { requestVertexNormals: true, requestWaterMask: true } },
  //     terrainProvider: null,
  //     shadows: false,
  //   }
  }],
};

export default defineComponent({
  name: 'globe', // 地球仪
  components: { SelectBox, SliderBar, viewerSettingSidebar, GlobeRotater, MousePosition },
  setup() {
    return {};
  },
  props: {},
  data() {
    return {
      g3v: null,
    };
  },
  computed: {
    viewer() {
      return this.g3v && this.g3v.viewer$1;
    },
    g3vViewer() {
      return this.g3v && this.g3v.g3vViewer$1;
    },
    viewerSource() {
      const { viewer } = this;
      return { viewer };
    },
    clockOptions(){
      return {multiplier:500}
    }
  },
  watch: {},
  mounted() {
    this.initViewer();
  },
  beforeUnmount() {},
  unmounted() {
    this.g3v && this.g3v.destroy();
    this.g3v = null;
  },
  methods: {
    initViewer() {
      let vm = this;
      vm.g3v = new G3V(g3vOptions,()=>{
        vm.onViewerInited();
        vm.initEffects();
      });
    },
    onViewerInited() {},
    initEffects() {}
  }
});
</script>

<style lang="less"></style>
